package com.chixing.day04_oop;
/*
    方法中的参数传递：
        （1）值传递：基本数据类型的值 被 复制了一份，有两个独立的值
                int a = 10;
                int b = a;
        （2）地址传递：引用数据类型的 赋值，指向同一个堆内存
                Car car1 = new Car(101,"劳斯莱斯");
                Car car2 = car1;
*/
public class MethodDemo {
    //值传递： 基本数据类型的值 被 复制了一份，有两个独立的值
    public static void fun1(int n){// n=x
        n = 20;
    }
    //地址传递：引用数据类型的 赋值，指向同一个堆内存
    public static void fun2(Car c){//Car c =car;
        c.setCarName("zzz");
        c.setCarBrand("劳斯莱斯");
    }
    public static void fun3(int[] a){
        a[0] = 99;
    }

    public static void main(String[] args) {
        int x= 10;
        fun1(x);
        System.out.println("x = " + x);

        Car car  =new Car(101,"ddd","特斯拉","黑色");
        fun2(car);
        System.out.println("car name:" + car.getCarName());

        int[] a = {10,20,30};
        fun3(a);
        System.out.println("a[0] = "+a[0]);
    }
}
